<?php

function win_observation_validation_requests() {
  $header = array(t('ID'), t('User'), t('Status'), t('Manage'));
  $rows = array();

  $query = 'SELECT wv.uid, u.name, wv.status FROM win_validators wv LEFT JOIN {users} u ON wv.uid = u.uid order by wv.status';
  $result = db_query($query);
  if (!$result) {
  }
  else {
    $status = array('Pending', 'Approved', 'Rejected');
    $i = 0;
    $base_path = base_path();
    $user_url = $base_path . 'user/';
    $manage_url = $base_path . 'observation/validator_request/';
    while ($obj = db_fetch_object($result)) {
      $uid = $obj->uid;
      $rows[$i] = array(
        t($i+1),
        '<a href="' . $user_url . $uid . '" target="_blank">' . $obj->name . '</a>',
        $status[$obj->status],
        '<a href="' . $manage_url . $uid . '" target="_blank">Manage</a>',
      );
      $i++;
    }
  }
  
  $output = theme('table', $header, $rows);
  $output .= drupal_render($form);

  return $output;
}